@extends('web.common.main2')
@section('css')
    <link rel="stylesheet" href="{{env('STATIC_PATH')}}/css/user.css">
@endsection


@section('container')
<div class="hb-banner hb-banner_login">
    <ul>
        <li style='background-image: url("img/login/bg.png")'></li>
    </ul>
    <div class="hb-contain">
        <form action="">
            <div class="form">
                <div class="tit">合伙人登录入口</div>

                <ul>
                  <img style="width:80%;margin:auto;margin-top:-20px" src="/img/ewm.png" alt="请关注公众号">
                  <div style="margin:10px auto;font-size:18px;text-align:center">请移步微信关注公众号注册绑定</div>
                </ul>
            </div>
        </form>
        <div class="text">
            <div class="tit">
                绿色项目 合伙平台
            </div>
            <div class="tip">
                标准实施 标准投资 一站式服务<br>
                让绿色项目落地变得更简单、更安全、更高效
            </div>
        </div>
    </div>
</div>
@endsection

@section('script')
<script>
    (function ($) {
        $(function () {
            //刷新验证码
            $(".j_changeCode").on("click", function () {
                var $t = $(this);
                $t.attr("src", "/captcha/login?" + new Date().getTime());
            });

            //提交
            $("#submit").click(function () {
                var $t = $(this);
                if($t.attr("class").indexOf("disable") === -1) {
                    var $phone = $("#username");
                    var phone = $phone.val();
                    if (!isPhone(phone)) {
                        return showErr($phone, "请输入正确的手机号码！");
                    }
                    var $pwd = $("#password");
                    var pwd = $pwd.val();
                    if (!pwd) {
                        return showErr($phone, "请输入密码！");
                    }
                    var $code = $("#code");
                    var vcode = "";
                    if ($code && $code.length > 0) {
                        vcode = $code.val();
                        if (!vcode) {
                            return showErr($phone, "请输入验证码！");
                        }
                    }
                    $.ajax({
                        url: "/login",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        data: {
                            phone: phone,
                            captcha: vcode,
                            pwd: pwd
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            var result = data["result"];
                            var msg = data["msg"];
                            var token = data["token"];
                            var j_url = data["url"];
                            var limit = data["login_error_limit"];
                            if (limit) {
                                location.reload();
                            }
                            if (result === 0) {
                                j_login(phone,token,j_url);
                                window.location.href="/user/account";
                                return false;
                            } else {
                                $(".j_changeCode").attr("src", "/captcha/login?" + new Date().getTime());
                                return showErr($t, msg);
                            }
                        },
                        error: function (data) {
                            return showErr($t, "登录失败！");
                        }
                    });
                }
            });

            //回车键提交
            $(document).on("keydown", function (event) {
                var e = event || window.event || arguments.callee.caller.arguments[0];
                if (e && e.keyCode == 13) {
                    $("#submit").click();
                }
            });
        });
    })(jQuery);
</script>
@endsection
